<%@ page language="java" errorPage="/error.jsp" pageEncoding="UTF-8" contentType="text/html;charset=utf-8"%>
<%@ include file="/WEB-INF/taglibs.jsp"%>
<%@ taglib uri="http://ckeditor.com" prefix="ckeditor" %>
<script type="text/javascript" src="${ctx}/resource/system/common/js/ajaxfileupload.js"></script>
<script type="text/javascript">
	$(function(){
		$("#serveMenu").addClass("cur");
	});
</script>

<div class="conTit fixed">
    <p>
   		<c:choose>
			<c:when test="${info.id ==null}">新增图文信息</c:when>
			<c:otherwise>修改图文信息</c:otherwise>
		</c:choose>
    </p>
    <div class="fr"><a href="javascript:void(0);" class="backBtn" onclick="window.history.back(-1);">返回</a></div>
</div>

<div style="margin-left: 10px;">
  <form id="carrierForm" action="" method="post">
	
	<div class="inputArea">
	    <label>描述:<font style="color: red">*</font></label>
	     <div class="inputLine">
	          <input type="text" id="description" name="description" value="${info.description}" />
	     </div>
	</div> 
		<div class="inputArea">
	    <label>图文:<font style="color: red">*</font></label>
    	 <div class="inputLine">
     		<textarea id="editor1" name="content">${info.msg}</textarea>
     		<ckeditor:replace replace="editor1" basePath="${ctx }/resource/module/ckeditor/" />
	     </div>
	</div>
 
	<div class="save">
	     <a href="javascript:void(0);" class="backBtn" onclick="saveCarrier()">保存</a>
	</div>
    <input type="hidden" name="id" value="${info.id}" />
  </form>
</div>
		
<script type="text/javascript">

function saveCarrier() {
	var description = $("#description").val();
	$("#editor1").val(CKEDITOR.instances.editor1.getData());
	var id = $("input[name=id]").val();	
	var content =$("#editor1").val();
	var success = true;
	
	if($.trim(description) ==""){
		alert("描述不能为空");
		success = false;
	}else if($.trim(content) ==""){
		alert("内容不能为空");
		success = false;
	}

	if(success){
		
		$.ajax({
			url:'${ctx}/admin/pictureText/save.json',
			type: "post",
			data:{id:id,description:description,content:content},
			dataType: 'json',//返回值类型 一般设置为json
			success: function (data, status) {
				if(data.status==true || data.status=="true") {
					alert("保存成功");
					window.location.reload();
				}else {
					layer.alert(data.msg);
				}
			}
		});
	}
}
</script>
